import 'package:flutter/material.dart';

class LicenseTxt extends StatefulWidget {
  const LicenseTxt({Key? key}) : super(key: key);

  @override
  _LicenseTxtState createState() => _LicenseTxtState();
}

class _LicenseTxtState extends State<LicenseTxt> {
  bool _checked = false;

  void _changeChecked() {
    setState(() {
      _checked=!_checked;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: GestureDetector(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              padding: EdgeInsets.only(
                left: 62.0,
                right: 10.0,
              ),
              child: Image(
                width: 16,
                height: 16,
                image: AssetImage(_checked? 'assets/icons/checked.png': 'assets/icons/unchecked.png'),
                fit: BoxFit.fill,
              ),
            ),

            /// 多行文本的第一个行与图片对齐
            /// 解决办法：设置行高为图片高度。此时行距极小不美观，需要单独设置行距。
            /// 若设置行距：还需向上偏移半个行距，才会最终实现对齐效果
            Expanded(
              child: Transform.translate(
                offset: Offset(0, -3.0), //StrutStyle 的 leading的值的一半
                child: Text(
                  "By using our App you agree with our Term of Use \n and Privacy Policy.",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 12.0,
                    height: 16.0, // 行高
                    decoration: TextDecoration.none,
                    fontFamily: 'Galada',
                  ),
                  strutStyle: StrutStyle(
                    forceStrutHeight: true,
                    height: 1,
                    leading: 0.5, //行距（0.5即行高的一半）
                  ),
                ),
              ),
            ),
          ],
        ),
        onTap: _changeChecked,
      ),
    );
  }
}




